# Replication code for Taylor C. Boas, Dino P. Christenson, and David M. Glick, "Recruiting Large Online Samples in the United States and India: Facebook, Mechanical Turk and Qualtrics," Political Science Research and Methods.

# Analysis conducted in R 3.4.3 on MacOS 10.13.2

# NOTE: This file produces Main Text Figure 9, related to the replication of survey experiments. Files should be run in the following order; please see readme.txt for details.
# 	1. clean_us_survey.R
# 	2. clean_india_survey.R
# 	3. merge_external_data_us.R
# 	4. merge_external_data_india.R
# 	5. analyze_demographics.R
# 	6. analyze_spaces.R
# 	7. analyze_politics.R
# 	8. analyze_cooperativeness.R
# 	9. analyze_experiments.R

# Set working directory as appropriate
# setwd('~/Dropbox/sample recruitment shared/replication/')

# Clean desktop and load packages. Please make sure all necessary packages are installed.
rm(list=ls(all=T))
library(foreign)
library(readstata13)
library(survey)
library(car)

# Load survey data. For Indian surveys, we do not have access to the original data. Population estimates used as benchmarks are taken from:
#	Reed, Megan N. and Devesh Kapur. 2015. “The love for sons and
#		appropriate attire.” The Hindu, January 26.
#	Kapur, Devesh, Neelanjan Sircar and Milan Vaishnav. 2014. “All in the
#		surname.” Times of India, March 23.

load('india_completions_augmented.RData')
load('us_completions_augmented.RData')
load('gss.RData')
load('kriner.RData')
load('hasel.RData')

# US sample for unweighted analysis: excluding targeted respondents in Facebook/MTurk samples

us1$nontarg<-((us1$sample=='Qualtrics')|(us1$sample=='Facebook'&us1$targ==0)|(us1$sample=='MTurk'&us1$StartDate <= as.POSIXct('2015-12-31 23:59:59 EST')))

##############################################
# Main Text Figure 9: Experimental Replication
##############################################

# India weighted design objects

india.fb.design<-svydesign(ids=~1,weights=india1$weight[india1$sample=='Facebook'], data=india1[india1$sample=='Facebook',])
india.mt.design<-svydesign(ids=~1,weights=india1$weight[india1$sample=='MTurk'], data=india1[india1$sample=='MTurk',])
india.qt.design<-svydesign(ids=~1,weights=india1$weight[india1$sample=='Qualtrics'], data=india1[india1$sample=='Qualtrics',])

# India: preference for male children (population estimate is 48%; see note above)

reg.india.malechild.fb<-with(india1[india1$sample=='Facebook',],lm(Q18~Q18_treat))
reg.india.malechild.mt<-with(india1[india1$sample=='MTurk',],lm(Q18~Q18_treat))
reg.india.malechild.qt<-with(india1[india1$sample=='Qualtrics',],lm(Q18~Q18_treat))

reg.india.malechild.fb.wtd<-svyglm(Q18~Q18_treat, design=india.fb.design)
reg.india.malechild.mt.wtd<-svyglm(Q18~Q18_treat, design=india.mt.design)
reg.india.malechild.qt.wtd<-svyglm(Q18~Q18_treat, design=india.qt.design)

# India: bothered by criminal candidate (population estimate is 52%; see note above)

reg.india.criminal.fb<-with(india1[india1$sample=='Facebook',],lm(Q19~Q19_treat))
reg.india.criminal.mt<-with(india1[india1$sample=='MTurk',],lm(Q19~Q19_treat))
reg.india.criminal.qt<-with(india1[india1$sample=='Qualtrics',],lm(Q19~Q19_treat))

reg.india.criminal.fb.wtd<-svyglm(Q19~Q19_treat, design=india.fb.design)
reg.india.criminal.mt.wtd<-svyglm(Q19~Q19_treat, design=india.mt.design)
reg.india.criminal.qt.wtd<-svyglm(Q19~Q19_treat, design=india.qt.design)

# US Party ID

us1$dem_rep<-1*(us1$Q9%in%1&us1$Q10%in%1)+2*(us1$Q9%in%1&us1$Q10%in%2)+3*(us1$Q9%in%3&us1$Q10_ind%in%3)+4*(us1$Q9%in%3&us1$Q10_ind%in%2)+5*(us1$Q9%in%3&us1$Q10_ind%in%1)+6*(us1$Q9%in%2&us1$Q10%in%2)+7*(us1$Q9%in%2&us1$Q10%in%1)
us1$dem_rep[us1$dem_rep==0]<-NA

# US weighted design objects

us.fb.design<-svydesign(ids=~1,weights=us1$weight[us1$sample=='Facebook'], data=us1[us1$sample=='Facebook',])
us.fb.design.dem<-subset(us.fb.design,dem_rep<4)
us.fb.design.gop<-subset(us.fb.design,dem_rep>4)

us.mt.design<-svydesign(ids=~1,weights=us1$weight[us1$sample=='MTurk'], data=us1[us1$sample=='MTurk',])
us.mt.design.dem<-subset(us.mt.design,dem_rep<4)
us.mt.design.gop<-subset(us.mt.design,dem_rep>4)

us.qt.design<-svydesign(ids=~1,weights=us1$weight[us1$sample=='Qualtrics'], data=us1[us1$sample=='Qualtrics',])
us.qt.design.dem<-subset(us.qt.design,dem_rep<4)
us.qt.design.gop<-subset(us.qt.design,dem_rep>4)

# US: Approve of home mortgage interest deduction/cash payment

hasel$housing.approve<-hasel$housing >= 5
hasel$dem_rep<-ifelse(hasel$pid7=='not sure',NA, unclass(hasel$pid7))

reg.hasel.housing<-lm(hasel$housing.approve~ hasel$taxgrant)
reg.hasel.housing.dem<-with(hasel[hasel$dem_rep<4,],lm(housing.approve~taxgrant))
reg.hasel.housing.gop<-with(hasel[hasel$dem_rep>4,],lm(housing.approve~taxgrant))

reg.us.housing.fb<-with(us1[us1$nontarg&us1$sample=='Facebook',],lm(I(Q20==1)~Q20_deduct))
reg.us.housing.fb.dem<-with(us1[us1$nontarg&us1$sample=='Facebook'&us1$dem_rep<4,],lm(I(Q20==1)~Q20_deduct))
reg.us.housing.fb.gop<-with(us1[us1$nontarg&us1$sample=='Facebook'&us1$dem_rep>4,],lm(I(Q20==1)~Q20_deduct))

reg.us.housing.mt<-with(us1[us1$nontarg&us1$sample=='MTurk',],lm(I(Q20==1)~Q20_deduct))
reg.us.housing.mt.dem<-with(us1[us1$nontarg&us1$sample=='MTurk'&us1$dem_rep<4,],lm(I(Q20==1)~Q20_deduct))
reg.us.housing.mt.gop<-with(us1[us1$nontarg&us1$sample=='MTurk'&us1$dem_rep>4,],lm(I(Q20==1)~Q20_deduct))

reg.us.housing.qt<-with(us1[us1$nontarg&us1$sample=='Qualtrics',],lm(I(Q20==1)~Q20_deduct))
reg.us.housing.qt.dem<-with(us1[us1$nontarg&us1$sample=='Qualtrics'&us1$dem_rep<4,],lm(I(Q20==1)~Q20_deduct))
reg.us.housing.qt.gop<-with(us1[us1$nontarg&us1$sample=='Qualtrics'&us1$dem_rep>4,],lm(I(Q20==1)~Q20_deduct))

reg.us.housing.fb.wtd<-svyglm(I(Q20==1)~Q20_deduct, design=us.fb.design)
reg.us.housing.fb.dem.wtd<-svyglm(I(Q20==1)~Q20_deduct, design=us.fb.design.dem)
reg.us.housing.fb.gop.wtd<-svyglm(I(Q20==1)~Q20_deduct, design=us.fb.design.gop)

reg.us.housing.mt.wtd<-svyglm(I(Q20==1)~Q20_deduct, design=us.mt.design)
reg.us.housing.mt.dem.wtd<-svyglm(I(Q20==1)~Q20_deduct, design=us.mt.design.dem)
reg.us.housing.mt.gop.wtd<-svyglm(I(Q20==1)~Q20_deduct, design=us.mt.design.gop)

reg.us.housing.qt.wtd<-svyglm(I(Q20==1)~Q20_deduct, design=us.qt.design)
reg.us.housing.qt.dem.wtd<-svyglm(I(Q20==1)~Q20_deduct, design=us.qt.design.dem)
reg.us.housing.qt.gop.wtd<-svyglm(I(Q20==1)~Q20_deduct, design=us.qt.design.gop)

# US: Approve of sending troops to Korea given draft/no draft (estimating as effect of "no draft" to get a positive treatment effect, like the others)

reg.kriner.troops<-with(kriner[kriner$control==1|kriner$draft==1,],lm(ksupportbin~!draft))
reg.kriner.troops.dem<-with(kriner[(kriner$control==1|kriner$draft==1)&kriner$dem5==1,],lm(ksupportbin~!draft))
reg.kriner.troops.gop<-with(kriner[(kriner$control==1|kriner$draft==1)&kriner$gop5==1,],lm(ksupportbin~!draft))

reg.us.troops.fb<-with(us1[us1$nontarg&us1$sample=='Facebook',],lm(I(Q19 %in% 1:2)~!Q19_draft))
reg.us.troops.fb.dem<-with(us1[us1$nontarg&us1$sample=='Facebook'&us1$dem_rep<4,],lm(I(Q19 %in% 1:2)~!Q19_draft))
reg.us.troops.fb.gop<-with(us1[us1$nontarg&us1$sample=='Facebook'&us1$dem_rep>4,],lm(I(Q19 %in% 1:2)~!Q19_draft))

reg.us.troops.mt<-with(us1[us1$nontarg&us1$sample=='MTurk',],lm(I(Q19 %in% 1:2)~!Q19_draft))
reg.us.troops.mt.dem<-with(us1[us1$nontarg&us1$sample=='MTurk'&us1$dem_rep<4,],lm(I(Q19 %in% 1:2)~!Q19_draft))
reg.us.troops.mt.gop<-with(us1[us1$nontarg&us1$sample=='MTurk'&us1$dem_rep>4,],lm(I(Q19 %in% 1:2)~!Q19_draft))

reg.us.troops.qt<-with(us1[us1$nontarg&us1$sample=='Qualtrics',],lm(I(Q19 %in% 1:2)~!Q19_draft))
reg.us.troops.qt.dem<-with(us1[us1$nontarg&us1$sample=='Qualtrics'&us1$dem_rep<4,],lm(I(Q19 %in% 1:2)~!Q19_draft))
reg.us.troops.qt.gop<-with(us1[us1$nontarg&us1$sample=='Qualtrics'&us1$dem_rep>4,],lm(I(Q19 %in% 1:2)~!Q19_draft))

reg.us.troops.fb.wtd<-svyglm(I(Q19 %in% 1:2)~!Q19_draft, design=us.fb.design)
reg.us.troops.fb.dem.wtd<-svyglm(I(Q19 %in% 1:2)~!Q19_draft, design=us.fb.design.dem)
reg.us.troops.fb.gop.wtd<-svyglm(I(Q19 %in% 1:2)~!Q19_draft, design=us.fb.design.gop)

reg.us.troops.mt.wtd<-svyglm(I(Q19 %in% 1:2)~!Q19_draft, design=us.mt.design)
reg.us.troops.mt.dem.wtd<-svyglm(I(Q19 %in% 1:2)~!Q19_draft, design=us.mt.design.dem)
reg.us.troops.mt.gop.wtd<-svyglm(I(Q19 %in% 1:2)~!Q19_draft, design=us.mt.design.gop)

reg.us.troops.qt.wtd<-svyglm(I(Q19 %in% 1:2)~!Q19_draft, design=us.qt.design)
reg.us.troops.qt.dem.wtd<-svyglm(I(Q19 %in% 1:2)~!Q19_draft, design=us.qt.design.dem)
reg.us.troops.qt.gop.wtd<-svyglm(I(Q19 %in% 1:2)~!Q19_draft, design=us.qt.design.gop)

# US: Approve of Welfare vs. Assistance for the poor. DV is "too much" being spent

gss$dem_rep<-ifelse(gss$partyid==7,NA,gss$partyid+1)
gss$welfare<-ifelse(is.na(gss$natfare), gss$natfarey, gss$natfare)
gss$welfare.treat<-is.na(gss$natfarey) & !is.na(gss$natfare)

reg.gss.welfare<-lm(I(gss$welfare==3) ~ gss$welfare.treat)
reg.gss.welfare.dem<-with(gss[gss$dem_rep < 4,],lm(I(welfare==3) ~ welfare.treat))
reg.gss.welfare.gop<-with(gss[gss$dem_rep > 4,],lm(I(welfare==3) ~ welfare.treat))

reg.us.welfare.fb<-with(us1[us1$nontarg&us1$sample=='Facebook',],lm(I(Q21a==3)~Q21a_welfare))
reg.us.welfare.fb.dem<-with(us1[us1$nontarg&us1$sample=='Facebook'&us1$dem_rep<4,],lm(I(Q21a==3)~Q21a_welfare))
reg.us.welfare.fb.gop<-with(us1[us1$nontarg&us1$sample=='Facebook'&us1$dem_rep>4,],lm(I(Q21a==3)~Q21a_welfare))

reg.us.welfare.mt<-with(us1[us1$nontarg&us1$sample=='MTurk',],lm(I(Q21a==3)~Q21a_welfare))
reg.us.welfare.mt.dem<-with(us1[us1$nontarg&us1$sample=='MTurk'&us1$dem_rep<4,],lm(I(Q21a==3)~Q21a_welfare))
reg.us.welfare.mt.gop<-with(us1[us1$nontarg&us1$sample=='MTurk'&us1$dem_rep>4,],lm(I(Q21a==3)~Q21a_welfare))

reg.us.welfare.qt<-with(us1[us1$nontarg&us1$sample=='Qualtrics',],lm(I(Q21a==3)~Q21a_welfare))
reg.us.welfare.qt.dem<-with(us1[us1$nontarg&us1$sample=='Qualtrics'&us1$dem_rep<4,],lm(I(Q21a==3)~Q21a_welfare))
reg.us.welfare.qt.gop<-with(us1[us1$nontarg&us1$sample=='Qualtrics'&us1$dem_rep>4,],lm(I(Q21a==3)~Q21a_welfare))

reg.us.welfare.fb.wtd<-svyglm(I(Q21a==3)~Q21a_welfare, design=us.fb.design)
reg.us.welfare.fb.dem.wtd<-svyglm(I(Q21a==3)~Q21a_welfare, design=us.fb.design.dem)
reg.us.welfare.fb.gop.wtd<-svyglm(I(Q21a==3)~Q21a_welfare, design=us.fb.design.gop)

reg.us.welfare.mt.wtd<-svyglm(I(Q21a==3)~Q21a_welfare, design=us.mt.design)
reg.us.welfare.mt.dem.wtd<-svyglm(I(Q21a==3)~Q21a_welfare, design=us.mt.design.dem)
reg.us.welfare.mt.gop.wtd<-svyglm(I(Q21a==3)~Q21a_welfare, design=us.mt.design.gop)

reg.us.welfare.qt.wtd<-svyglm(I(Q21a==3)~Q21a_welfare, design=us.qt.design)
reg.us.welfare.qt.dem.wtd<-svyglm(I(Q21a==3)~Q21a_welfare, design=us.qt.design.dem)
reg.us.welfare.qt.gop.wtd<-svyglm(I(Q21a==3)~Q21a_welfare, design=us.qt.design.gop)

# Gather coefficients

ate.rep<-c(sapply(list(reg.hasel.housing, reg.hasel.housing.dem, reg.hasel.housing.gop, reg.kriner.troops, reg.kriner.troops.dem, reg.kriner.troops.gop, reg.gss.welfare, reg.gss.welfare.dem, reg.gss.welfare.gop), function(x) coef(x)[2]), .48, .52) # See start of file for source of the Indian survey experiment population estimates of 0.48 and 0.52
ate.fb<-sapply(list(reg.us.housing.fb, reg.us.housing.fb.dem, reg.us.housing.fb.gop, reg.us.troops.fb, reg.us.troops.fb.dem, reg.us.troops.fb.gop, reg.us.welfare.fb, reg.us.welfare.fb.dem, reg.us.welfare.fb.gop, reg.india.malechild.fb, reg.india.criminal.fb), function(x) coef(x)[2])
ate.fb.wtd<-sapply(list(reg.us.housing.fb.wtd, reg.us.housing.fb.dem.wtd, reg.us.housing.fb.gop.wtd, reg.us.troops.fb.wtd, reg.us.troops.fb.dem.wtd, reg.us.troops.fb.gop.wtd, reg.us.welfare.fb.wtd, reg.us.welfare.fb.dem.wtd, reg.us.welfare.fb.gop.wtd, reg.india.malechild.fb.wtd, reg.india.criminal.fb.wtd), function(x) coef(x)[2])
ate.mt<-sapply(list(reg.us.housing.mt, reg.us.housing.mt.dem, reg.us.housing.mt.gop, reg.us.troops.mt, reg.us.troops.mt.dem, reg.us.troops.mt.gop, reg.us.welfare.mt, reg.us.welfare.mt.dem, reg.us.welfare.mt.gop, reg.india.malechild.mt, reg.india.criminal.mt), function(x) coef(x)[2])
ate.mt.wtd<-sapply(list(reg.us.housing.mt.wtd, reg.us.housing.mt.dem.wtd, reg.us.housing.mt.gop.wtd, reg.us.troops.mt.wtd, reg.us.troops.mt.dem.wtd, reg.us.troops.mt.gop.wtd, reg.us.welfare.mt.wtd, reg.us.welfare.mt.dem.wtd, reg.us.welfare.mt.gop.wtd, reg.india.malechild.mt.wtd, reg.india.criminal.mt.wtd), function(x) coef(x)[2])
ate.qt<-sapply(list(reg.us.housing.qt, reg.us.housing.qt.dem, reg.us.housing.qt.gop, reg.us.troops.qt, reg.us.troops.qt.dem, reg.us.troops.qt.gop, reg.us.welfare.qt, reg.us.welfare.qt.dem, reg.us.welfare.qt.gop, reg.india.malechild.qt, reg.india.criminal.qt), function(x) coef(x)[2])
ate.qt.wtd<-sapply(list(reg.us.housing.qt.wtd, reg.us.housing.qt.dem.wtd, reg.us.housing.qt.gop.wtd, reg.us.troops.qt.wtd, reg.us.troops.qt.dem.wtd, reg.us.troops.qt.gop.wtd, reg.us.welfare.qt.wtd, reg.us.welfare.qt.dem.wtd, reg.us.welfare.qt.gop.wtd, reg.india.malechild.qt.wtd, reg.india.criminal.qt.wtd), function(x) coef(x)[2])

se.rep<-c(sapply(list(reg.hasel.housing, reg.hasel.housing.dem, reg.hasel.housing.gop, reg.kriner.troops, reg.kriner.troops.dem, reg.kriner.troops.gop, reg.gss.welfare, reg.gss.welfare.dem, reg.gss.welfare.gop), function(x) coef(summary(x))[2,2]), NA, NA)
se.fb<-sapply(list(reg.us.housing.fb, reg.us.housing.fb.dem, reg.us.housing.fb.gop, reg.us.troops.fb, reg.us.troops.fb.dem, reg.us.troops.fb.gop, reg.us.welfare.fb, reg.us.welfare.fb.dem, reg.us.welfare.fb.gop, reg.india.malechild.fb, reg.india.criminal.fb), function(x) coef(summary(x))[2,2])
se.fb.wtd<-sapply(list(reg.us.housing.fb.wtd, reg.us.housing.fb.dem.wtd, reg.us.housing.fb.gop.wtd, reg.us.troops.fb.wtd, reg.us.troops.fb.dem.wtd, reg.us.troops.fb.gop.wtd, reg.us.welfare.fb.wtd, reg.us.welfare.fb.dem.wtd, reg.us.welfare.fb.gop.wtd, reg.india.malechild.fb.wtd, reg.india.criminal.fb.wtd), function(x) coef(summary(x))[2,2])
se.mt<-sapply(list(reg.us.housing.mt, reg.us.housing.mt.dem, reg.us.housing.mt.gop, reg.us.troops.mt, reg.us.troops.mt.dem, reg.us.troops.mt.gop, reg.us.welfare.mt, reg.us.welfare.mt.dem, reg.us.welfare.mt.gop, reg.india.malechild.mt, reg.india.criminal.mt), function(x) coef(summary(x))[2,2])
se.mt.wtd<-sapply(list(reg.us.housing.mt.wtd, reg.us.housing.mt.dem.wtd, reg.us.housing.mt.gop.wtd, reg.us.troops.mt.wtd, reg.us.troops.mt.dem.wtd, reg.us.troops.mt.gop.wtd, reg.us.welfare.mt.wtd, reg.us.welfare.mt.dem.wtd, reg.us.welfare.mt.gop.wtd, reg.india.malechild.mt.wtd, reg.india.criminal.mt.wtd), function(x) coef(summary(x))[2,2])
se.qt<-sapply(list(reg.us.housing.qt, reg.us.housing.qt.dem, reg.us.housing.qt.gop, reg.us.troops.qt, reg.us.troops.qt.dem, reg.us.troops.qt.gop, reg.us.welfare.qt, reg.us.welfare.qt.dem, reg.us.welfare.qt.gop, reg.india.malechild.qt, reg.india.criminal.qt), function(x) coef(summary(x))[2,2])
se.qt.wtd<-sapply(list(reg.us.housing.qt.wtd, reg.us.housing.qt.dem.wtd, reg.us.housing.qt.gop.wtd, reg.us.troops.qt.wtd, reg.us.troops.qt.dem.wtd, reg.us.troops.qt.gop.wtd, reg.us.welfare.qt.wtd, reg.us.welfare.qt.dem.wtd, reg.us.welfare.qt.gop.wtd, reg.india.malechild.qt.wtd, reg.india.criminal.qt.wtd), function(x) coef(summary(x))[2,2])

# Dot-plot figure

lwd<-1.5
adjust<-0.15
nvars<-length(ate.rep)

pdf(file='experiments.pdf',width=10,height=7)
par(mfrow=c(1,2))

par(mar=c(3,7,2,0)+.01)
plot(ate.rep, nvars:1+1.5*adjust, type='p',axes=F,frame.plot=T,xlab='',ylab='',pch=19,xlim=0:1,ylim=c(1-1.5*adjust,nvars+1.5*adjust),main='Unweighted',sub='')
Axis(side=1,at=seq(0,1,.25),labels= seq(0,1,.25))
Axis(side=2,at=c((nvars+1):0),labels=c('','All','Democrat','GOP','All','Democrat','GOP','All','Democrat','GOP','Prefer\nSons', 'Criminal\nCandidates',''),las=1)
Axis(side=2,at=c(1.5,4,7,10),labels=c('India','US: Welfare','US: Draft','US: Mortgage'), line=4.5,tick=F,font=2)
abline(h=1:(nvars-1)+.5,lwd=1,lty=3)
abline(h=c(2.5,5.5,8.5),lwd=1,lty=1)
segments(ate.rep-qnorm(.975)*se.rep,nvars:1+1.5*adjust, ate.rep+qnorm(.975)*se.rep,nvars:1+1.5*adjust,lwd=lwd)
segments(ate.fb-qnorm(.975)*se.fb,nvars:1+0.5*adjust, ate.fb+qnorm(.975)*se.fb,nvars:1+0.5*adjust,lwd=lwd)
segments(ate.mt-qnorm(.975)*se.mt,nvars:1-0.5*adjust, ate.mt+qnorm(.975)*se.mt,nvars:1-0.5*adjust,lwd=lwd)
segments(ate.qt-qnorm(.975)*se.qt,nvars:1-1.5*adjust, ate.qt+qnorm(.975)*se.qt,nvars:1-1.5*adjust,lwd=lwd)
points(ate.fb, nvars:1+0.5*adjust, pch=21, bg='white')
points(ate.mt, nvars:1-0.5*adjust, pch=8)
points(ate.qt, nvars:1-1.5*adjust, pch=25, bg='white')

par(mar=c(3,2,2,5)+.01)
plot(ate.rep, nvars:1+1.5*adjust, type='p',axes=F,frame.plot=T,xlab='',ylab='',pch=19,xlim=0:1,ylim=c(1-1.5*adjust,nvars+1.5*adjust),main='Weighted',sub='')
Axis(side=1,at=seq(0,1,.25),labels= seq(0,1,.25))
abline(h=1:(nvars-1)+.5,lwd=1,lty=3)
abline(h=c(2.5,5.5,8.5),lwd=1,lty=1)
segments(ate.rep-qnorm(.975)*se.rep,nvars:1+1.5*adjust, ate.rep+qnorm(.975)*se.rep,nvars:1+1.5*adjust,lwd=lwd)
segments(ate.fb.wtd-qnorm(.975)*se.fb.wtd,nvars:1+0.5*adjust, ate.fb.wtd+qnorm(.975)*se.fb.wtd,nvars:1+0.5*adjust,lwd=lwd)
segments(ate.mt.wtd-qnorm(.975)*se.mt.wtd,nvars:1-0.5*adjust, ate.mt.wtd+qnorm(.975)*se.mt.wtd,nvars:1-0.5*adjust,lwd=lwd)
segments(ate.qt.wtd-qnorm(.975)*se.qt.wtd,nvars:1-1.5*adjust, ate.qt.wtd+qnorm(.975)*se.qt.wtd,nvars:1-1.5*adjust,lwd=lwd)
points(ate.fb.wtd, nvars:1+0.5*adjust, pch=21, bg='white')
points(ate.mt.wtd, nvars:1-0.5*adjust, pch=8)
points(ate.qt.wtd, nvars:1-1.5*adjust, pch=25, bg='white')
legend('right',pch=c(19,21,8,25),legend=c('Benchmark','Facebook','MTurk','Qualtrics'),title='Sample',bg='white')
dev.off()

